//调用摄像头 麦克风
const constraints = { audio: false, video: { facingMode: 'user' } }

export default function callCamera(video) {
  try {
    //mediaDevices只有安全上下文可以使用
    navigator.mediaDevices
      .getUserMedia(constraints)
      .then(function (mediaStream) {
        video.srcObject = mediaStream
        video.onloadedmetadata = function () {
          video.play()
        }
      })
      .catch(function (err) {
        console.log(err.name + ': ' + err.message)
      })
  } catch (error) {
    console.log(error)
  }
}
